/*
 Navicat Premium Data Transfer

 Source Server         : 127.0.0.1
 Source Server Type    : MySQL
 Source Server Version : 80028
 Source Host           : localhost:3306
 Source Schema         : zcoj

 Target Server Type    : MySQL
 Target Server Version : 80028
 File Encoding         : 65001

 Date: 23/05/2023 17:35:30
*/

create database zcoj;
Use zcoj;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for admin_sys_notice
-- ----------------------------
DROP TABLE IF EXISTS `admin_sys_notice`;
CREATE TABLE `admin_sys_notice` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) DEFAULT NULL COMMENT '标题',
  `content` longtext COMMENT '内容',
  `state` tinyint(1) DEFAULT '0' COMMENT '是否已拉取给用户',
  `recipient_id` int unsigned NOT NULL COMMENT '接受通知的用户id',
  `admin_id` int unsigned NOT NULL COMMENT '发送通知的管理员id',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '修改时间',
  PRIMARY KEY (`id`),
  KEY `recipient_id` (`recipient_id`),
  KEY `admin_id` (`admin_id`),
  CONSTRAINT `admin_sys_notice_ibfk_1` FOREIGN KEY (`recipient_id`) REFERENCES `user` (`id`),
  CONSTRAINT `admin_sys_notice_ibfk_2` FOREIGN KEY (`admin_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;


-- ----------------------------
-- Table structure for announcement
-- ----------------------------
DROP TABLE IF EXISTS `announcement`;
CREATE TABLE `announcement` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL COMMENT '标题',
  `content` longtext COMMENT '公告内容',
  `uid` int unsigned NOT NULL COMMENT '用户ID',
  `cid` int DEFAULT '0',
  `gid` int DEFAULT '0',
  `author` varchar(50) DEFAULT NULL,
  `status` int unsigned DEFAULT '1' COMMENT '1可见，0不可见',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `uid` (`uid`),
  CONSTRAINT `announcement_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of announcement
-- ----------------------------


-- ----------------------------
-- Table structure for code_template
-- ----------------------------
DROP TABLE IF EXISTS `code_template`;
CREATE TABLE `code_template` (
  `id` int NOT NULL AUTO_INCREMENT,
  `pid` int unsigned NOT NULL,
  `lid` int unsigned NOT NULL,
  `code` longtext NOT NULL,
  `status` tinyint(1) DEFAULT '0',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pid` (`pid`),
  KEY `lid` (`lid`),
  CONSTRAINT `code_template_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `code_template_ibfk_2` FOREIGN KEY (`lid`) REFERENCES `language` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;



-- ----------------------------
-- Table structure for comment
-- ----------------------------
DROP TABLE IF EXISTS `comment`;
CREATE TABLE `comment` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `cid` int unsigned DEFAULT '0' COMMENT 'null表示无引用比赛',
  `did` int unsigned DEFAULT '0' COMMENT 'null表示无引用讨论',
  `gid` int DEFAULT '0',
  `tid` int DEFAULT '0',
  `content` longtext COMMENT '评论内容',
  `level` int DEFAULT '0',
  `from_uid` int unsigned NOT NULL COMMENT '评论者id',
  `from_name` varchar(20) DEFAULT NULL COMMENT '评论者用户名',
  `from_avatar` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '评论组头像地址',
  `from_role` varchar(20) DEFAULT NULL COMMENT '评论者角色',
  `like_num` int DEFAULT '0' COMMENT '点赞数量',
  `status` int DEFAULT '0' COMMENT '是否封禁或逻辑删除该评论',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `comment_ibfk_1` (`cid`),
  KEY `did` (`did`),
  KEY `from_uid` (`from_uid`),
  CONSTRAINT `comment_ibfk_3` FOREIGN KEY (`from_uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of comment
-- ----------------------------


-- ----------------------------
-- Table structure for comment_like
-- ----------------------------
DROP TABLE IF EXISTS `comment_like`;
CREATE TABLE `comment_like` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `uid` int unsigned NOT NULL,
  `cid` int unsigned NOT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `comment_like_ibfk_1` (`uid`),
  KEY `comment_like_ibfk_2` (`cid`),
  CONSTRAINT `comment_like_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `comment_like_ibfk_2` FOREIGN KEY (`cid`) REFERENCES `comment` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of comment_like
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for contest
-- ----------------------------
DROP TABLE IF EXISTS `contest`;
CREATE TABLE `contest` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `avatar` varchar(70) DEFAULT NULL COMMENT '比赛图像',
  `uid` int unsigned NOT NULL COMMENT '比赛创建者id',
  `author` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '比赛创建者的用户名',
  `title` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '比赛标题',
  `type` int NOT NULL DEFAULT '1' COMMENT '0为acm赛制，1为比分赛制',
  `description` longtext COMMENT '比赛说明',
  `auth` int NOT NULL COMMENT '1为公开赛，2为私有赛（访问有密码)',
  `pwd` varchar(255) DEFAULT NULL COMMENT '比赛密码',
  `start_time` datetime DEFAULT NULL COMMENT '开始时间',
  `end_time` datetime DEFAULT NULL COMMENT '结束时间',
  `duration` int DEFAULT NULL COMMENT '比赛时长(s)',
  `seal_rank` int DEFAULT '1' COMMENT '是否开启封榜 0不开启 1开启',
  `seal_rank_time` datetime DEFAULT NULL COMMENT '封榜起始时间，一直到比赛结束，不刷新榜单',
  `auto_real_rank` int DEFAULT '1' COMMENT '比赛结束是否自动解除封榜,自动转换成真实榜单 0否 1是',
  `status` int NOT NULL COMMENT '-1为未开始，0为进行中，1为已结束',
  `visible` int DEFAULT '1' COMMENT '是否可见 0不可见 1可见',
  `open_rank` tinyint(1) DEFAULT '0' COMMENT '是否开放比赛榜单',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `uid` (`uid`),
  CONSTRAINT `contest_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of contest
-- ----------------------------


-- ----------------------------
-- Table structure for contest_announcement
-- ----------------------------
DROP TABLE IF EXISTS `contest_announcement`;
CREATE TABLE `contest_announcement` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `aid` int unsigned NOT NULL COMMENT '公告id',
  `cid` int unsigned NOT NULL COMMENT '比赛id',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `contest_announcement_ibfk_1` (`cid`),
  KEY `contest_announcement_ibfk_2` (`aid`),
  CONSTRAINT `contest_announcement_ibfk_1` FOREIGN KEY (`cid`) REFERENCES `contest` (`id`),
  CONSTRAINT `contest_announcement_ibfk_2` FOREIGN KEY (`aid`) REFERENCES `announcement` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of contest_announcement
-- ----------------------------


-- ----------------------------
-- Table structure for contest_problem
-- ----------------------------
DROP TABLE IF EXISTS `contest_problem`;
CREATE TABLE `contest_problem` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `display_id` int DEFAULT NULL COMMENT '该题目在比赛中的顺序id',
  `cid` int unsigned NOT NULL COMMENT '比赛id',
  `pid` int unsigned NOT NULL COMMENT '题目id',
  `display_title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '该题目在比赛中的标题，默认为原名字',
  `color` varchar(255) DEFAULT NULL COMMENT '气球颜色',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `contest_problem_ibfk_1` (`cid`),
  KEY `contest_problem_ibfk_2` (`pid`),
  CONSTRAINT `contest_problem_ibfk_1` FOREIGN KEY (`cid`) REFERENCES `contest` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contest_problem_ibfk_2` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of contest_problem
-- ----------------------------


-- ----------------------------
-- Table structure for contest_record
-- ----------------------------
DROP TABLE IF EXISTS `contest_record`;
CREATE TABLE `contest_record` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `cid` int unsigned DEFAULT NULL COMMENT '比赛id',
  `uid` int unsigned NOT NULL COMMENT '用户id',
  `pid` int unsigned DEFAULT NULL COMMENT '题目id',
  `cpid` int unsigned DEFAULT NULL COMMENT '比赛中的题目的id',
  `username` varchar(20) DEFAULT NULL COMMENT '用户名',
  `realname` varchar(20) DEFAULT NULL COMMENT '真实姓名',
  `submit_id` int unsigned NOT NULL COMMENT '提交id，用于可重判',
  `status` int DEFAULT NULL COMMENT '提交结果，0表示未AC通过不罚时，1表示AC通过，-1为未AC通过算罚时',
  `submit_time` datetime NOT NULL COMMENT '具体提交时间',
  `time` bigint unsigned DEFAULT NULL COMMENT '提交用时，为提交时间减去比赛时间 hh:mm:ss',
  `score` int DEFAULT NULL COMMENT 'OI比赛的得分',
  `use_time` int unsigned DEFAULT '0' COMMENT '运行耗时ms',
  `first_blood` tinyint(1) DEFAULT '0' COMMENT '是否为一血AC 0否1是',
  `checked` tinyint(1) DEFAULT '0' COMMENT 'AC是否已校验',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `contest_record_ibfk_1` (`cid`),
  KEY `contest_record_ibfk_2` (`uid`),
  KEY `contest_record_ibfk_3` (`pid`),
  KEY `contest_record_ibfk_4` (`cpid`),
  KEY `contest_record_ibfk_5` (`submit_id`),
  CONSTRAINT `contest_record_ibfk_1` FOREIGN KEY (`cid`) REFERENCES `contest` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contest_record_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contest_record_ibfk_3` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contest_record_ibfk_4` FOREIGN KEY (`cpid`) REFERENCES `contest_problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contest_record_ibfk_5` FOREIGN KEY (`submit_id`) REFERENCES `judge` (`submit_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of contest_record
-- ----------------------------


-- ----------------------------
-- Table structure for contest_register
-- ----------------------------
DROP TABLE IF EXISTS `contest_register`;
CREATE TABLE `contest_register` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `cid` int unsigned NOT NULL COMMENT '比赛id',
  `uid` int unsigned NOT NULL COMMENT '用户id',
  `status` int DEFAULT '0' COMMENT '默认为1表示正常，0为失效。\n1 正常\n2 禁止\n3 审批ing',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `contest_register_ibfk_1` (`cid`),
  KEY `contest_register_ibfk_2` (`uid`),
  CONSTRAINT `contest_register_ibfk_1` FOREIGN KEY (`cid`) REFERENCES `contest` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contest_register_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of contest_register
-- ----------------------------


-- ----------------------------
-- Table structure for discussion
-- ----------------------------
DROP TABLE IF EXISTS `discussion`;
CREATE TABLE `discussion` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `category_id` int unsigned NOT NULL COMMENT '分类id',
  `title` varchar(255) DEFAULT NULL COMMENT '讨论标题',
  `description` varchar(255) DEFAULT NULL COMMENT '讨论简介',
  `content` longtext COMMENT '讨论内容',
  `pid` int unsigned DEFAULT NULL COMMENT '关联题目id',
  `uid` int unsigned NOT NULL COMMENT '发表者id',
  `author` varchar(20) NOT NULL COMMENT '发表者用户名',
  `face_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '发表讨论者头像',
  `role` varchar(20) DEFAULT 'user' COMMENT '发表者角色',
  `view_num` int DEFAULT '0' COMMENT '浏览数量',
  `like_num` int DEFAULT '0' COMMENT '点赞数量',
  `top_priority` tinyint(1) DEFAULT '0' COMMENT '优先级，是否置顶 0否 1是',
  `comment_num` int DEFAULT '0' COMMENT '评论数量',
  `status` int DEFAULT '1' COMMENT '是否封禁该讨论 0否 1是',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `pid` (`pid`),
  KEY `uid` (`uid`),
  KEY `author` (`author`),
  KEY `category_id` (`category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of discussion
-- ----------------------------


-- ----------------------------
-- Table structure for discussion_category
-- ----------------------------
DROP TABLE IF EXISTS `discussion_category`;
CREATE TABLE `discussion_category` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分类名称',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of discussion_category
-- ----------------------------
BEGIN;
INSERT INTO `discussion_category` (`id`, `name`, `create_time`, `update_time`) VALUES (1, 'BUG', '2023-04-06 09:50:42', '2023-04-06 09:50:50');
INSERT INTO `discussion_category` (`id`, `name`, `create_time`, `update_time`) VALUES (2, '优化版块', '2023-04-06 09:51:11', '2023-04-06 09:51:14');
INSERT INTO `discussion_category` (`id`, `name`, `create_time`, `update_time`) VALUES (3, '题解版块', '2023-04-06 09:51:41', '2023-04-06 09:51:44');
INSERT INTO `discussion_category` (`id`, `name`, `create_time`, `update_time`) VALUES (4, '算法版块', '2023-04-06 09:52:06', '2023-04-06 09:52:09');
INSERT INTO `discussion_category` (`id`, `name`, `create_time`, `update_time`) VALUES (5, '博客版块', '2023-04-06 09:58:03', '2023-04-06 09:58:06');
INSERT INTO `discussion_category` (`id`, `name`, `create_time`, `update_time`) VALUES (6, '闲聊版块', '2023-04-06 10:14:49', '2023-04-06 10:14:53');
COMMIT;

-- ----------------------------
-- Table structure for discussion_like
-- ----------------------------
DROP TABLE IF EXISTS `discussion_like`;
CREATE TABLE `discussion_like` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `uid` int unsigned NOT NULL,
  `did` int unsigned NOT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `discussion_like_ibfk_1` (`did`),
  KEY `discussion_like_ibfk_2` (`uid`),
  CONSTRAINT `discussion_like_ibfk_1` FOREIGN KEY (`did`) REFERENCES `discussion` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `discussion_like_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of discussion_like
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for discussion_report
-- ----------------------------
DROP TABLE IF EXISTS `discussion_report`;
CREATE TABLE `discussion_report` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `did` int unsigned DEFAULT NULL COMMENT '讨论id',
  `reporter` varchar(20) DEFAULT NULL COMMENT '举报者的用户名',
  `uid` int DEFAULT NULL,
  `content` varchar(255) NOT NULL COMMENT '举报内容',
  `status` int DEFAULT '0' COMMENT '是否已读 0未读 1已读',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `did` (`did`),
  KEY `reporter` (`reporter`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of discussion_report
-- ----------------------------


-- ----------------------------
-- Table structure for file
-- ----------------------------
DROP TABLE IF EXISTS `file`;
CREATE TABLE `file` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `uid` int unsigned DEFAULT NULL COMMENT '用户id',
  `name` varchar(255) NOT NULL COMMENT '文件名',
  `suffix` varchar(255) NOT NULL COMMENT '文件后缀格式',
  `folder_path` varchar(255) NOT NULL COMMENT '文件所在文件夹的路径',
  `file_path` varchar(255) DEFAULT NULL COMMENT '文件绝对路径',
  `type` varchar(255) DEFAULT NULL COMMENT '文件所属类型，例如avatar',
  `delete` tinyint(1) DEFAULT '0' COMMENT '是否删除',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `file_ibfk_1` (`uid`),
  CONSTRAINT `file_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of file
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for filing
-- ----------------------------
DROP TABLE IF EXISTS `filing`;
CREATE TABLE `filing` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `filing_number` varchar(50) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of filing
-- ----------------------------
BEGIN;
INSERT INTO `filing` (`id`, `filing_number`, `create_time`, `update_time`) VALUES (1, '豫ICP备2021019646号-2', '2023-05-22 19:08:47', '2023-05-23 16:01:56');
COMMIT;

-- ----------------------------
-- Table structure for group
-- ----------------------------
DROP TABLE IF EXISTS `group`;
CREATE TABLE `group` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `face_url` varchar(255) DEFAULT NULL COMMENT '头像地址',
  `name` varchar(25) DEFAULT NULL COMMENT '团队名称',
  `short_name` varchar(10) DEFAULT NULL COMMENT '团队简称，创建题目时题号自动添加的前缀',
  `brief` varchar(50) DEFAULT NULL COMMENT '团队简介',
  `description` longtext COMMENT '团队介绍',
  `owner` varchar(50) NOT NULL COMMENT '团队拥有者用户名',
  `uid` int unsigned NOT NULL COMMENT '团队拥有者用户id',
  `auth` int NOT NULL COMMENT '1为Public，2为Private',
  `visible` int DEFAULT '1' COMMENT '是否可见',
  `status` int DEFAULT '0' COMMENT '是否封禁',
  `code` varchar(6) DEFAULT NULL COMMENT '邀请码(6位)',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `uid` (`uid`),
  CONSTRAINT `group_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1032 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of group
-- ----------------------------


-- ----------------------------
-- Table structure for group_announcement
-- ----------------------------
DROP TABLE IF EXISTS `group_announcement`;
CREATE TABLE `group_announcement` (
  `id` int NOT NULL AUTO_INCREMENT,
  `aid` int DEFAULT NULL,
  `gid` int DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of group_announcement
-- ----------------------------


-- ----------------------------
-- Table structure for group_member
-- ----------------------------
DROP TABLE IF EXISTS `group_member`;
CREATE TABLE `group_member` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `gid` int unsigned NOT NULL COMMENT '团队id',
  `uid` int unsigned NOT NULL COMMENT '用户id',
  `auth` int DEFAULT '1' COMMENT '1 未审批，2拒绝，3通过 \n',
  `reason` varchar(100) DEFAULT NULL COMMENT '申请理由',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `group_member_ibfk_1` (`gid`),
  KEY `group_member_ibfk_2` (`uid`),
  CONSTRAINT `group_member_ibfk_1` FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `group_member_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of group_member
-- ----------------------------


-- ----------------------------
-- Table structure for group_problem
-- ----------------------------
DROP TABLE IF EXISTS `group_problem`;
CREATE TABLE `group_problem` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `gid` int DEFAULT NULL,
  `pid` int DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of group_problem
-- ----------------------------

-- ----------------------------
-- Table structure for group_register
-- ----------------------------
DROP TABLE IF EXISTS `group_register`;
CREATE TABLE `group_register` (
  `id` int NOT NULL AUTO_INCREMENT,
  `gid` int DEFAULT NULL,
  `uid` int DEFAULT NULL,
  `status` int unsigned NOT NULL DEFAULT '0' COMMENT '0为未通过，1审核中，3通过',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of group_register
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for judge
-- ----------------------------
DROP TABLE IF EXISTS `judge`;
CREATE TABLE `judge` (
  `submit_id` int unsigned NOT NULL AUTO_INCREMENT,
  `pid` int unsigned DEFAULT NULL COMMENT '题目id',
  `p_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '题目名称',
  `uid` int unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  `gid` int unsigned DEFAULT '0' COMMENT '团队id，不为团队内提交则为 0',
  `tid` int DEFAULT '0' COMMENT '训练id',
  `cid` int DEFAULT '0' COMMENT '比赛id，非比赛题目默认为0',
  `cpid` int unsigned DEFAULT '0' COMMENT '比赛中题目排序id，非比赛题目默认为0',
  `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '用户名',
  `submit_time` datetime DEFAULT NULL COMMENT '提交的时间',
  `status` int DEFAULT '9' COMMENT '结果码具体参考文档',
  `visit` int unsigned DEFAULT '1' COMMENT '是否可见，1可见，0不可见',
  `share` tinyint(1) DEFAULT '0' COMMENT '0为仅自己可见，1为全部人可见。',
  `error_message` mediumtext COMMENT '错误提醒（编译错误，或者vj提醒）',
  `time` int DEFAULT '0' COMMENT '运行时间(ms)',
  `memory` int DEFAULT NULL COMMENT '运行内存（kb）',
  `score` int DEFAULT '0' COMMENT '分数',
  `length` int DEFAULT NULL COMMENT '代码长度',
  `code` longtext CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '代码',
  `language` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '代码语言',
  `judger` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '判题源',
  `ip` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '提交者所在ip',
  `oi_rank_score` int unsigned DEFAULT '0' COMMENT 'oi排行榜得分',
  `is_manual` tinyint(1) DEFAULT '0' COMMENT '是否为人工评测 0不是 1是',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`submit_id`)
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of judge
-- ----------------------------

-- ----------------------------
-- Table structure for judge_case
-- ----------------------------
DROP TABLE IF EXISTS `judge_case`;
CREATE TABLE `judge_case` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `sid` int unsigned NOT NULL COMMENT 'Judge表提交测评id',
  `pid` int unsigned NOT NULL COMMENT '问题表的id',
  `uid` int unsigned NOT NULL COMMENT '用户id',
  `status` int NOT NULL COMMENT '单个样例测评结果',
  `score` int DEFAULT NULL COMMENT '分数',
  `time` int unsigned NOT NULL DEFAULT '0' COMMENT '运行时间',
  `memory` int unsigned NOT NULL DEFAULT '0' COMMENT '运行内存',
  `case_id` int unsigned NOT NULL COMMENT '测试案例id',
  `input_name` varchar(20) NOT NULL COMMENT '样例输入文件名',
  `output_name` varchar(20) NOT NULL COMMENT '样例输出文件名',
  `message` longtext COMMENT '信息提示',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `sid` (`sid`),
  KEY `pid` (`pid`),
  KEY `uid` (`uid`),
  KEY `case_id` (`case_id`)
) ENGINE=InnoDB AUTO_INCREMENT=217 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of judge_case
-- ----------------------------


-- ----------------------------
-- Table structure for judge_result
-- ----------------------------
DROP TABLE IF EXISTS `judge_result`;
CREATE TABLE `judge_result` (
  `id` int NOT NULL AUTO_INCREMENT,
  `code` int DEFAULT NULL,
  `name` varchar(50) DEFAULT NULL,
  `color` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `enums` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of judge_result
-- ----------------------------
BEGIN;
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (1, -10, '未提交', 'rgba(248,163,5,0.8)', 'STATUS_NOT_SUBMITTED', '2023-04-12 09:14:35', '2023-04-12 09:14:37');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (2, 9, '提交中', 'rgba(133,243,9,0.8)', 'STATUS_SUBMITTING', '2023-04-12 09:15:28', '2023-04-12 09:15:32');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (3, 6, '编译中', 'rgba(8,201,61,0.8)', 'STATUS_PENDING', '2023-04-12 09:16:14', '2023-04-12 09:16:16');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (4, 7, '测评中', 'rgba(133,51,236,0.8)', 'STATUS_JUDGING', '2023-04-12 09:17:28', '2023-04-12 09:17:30');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (5, -2, '编译错误', 'rgba(248,5,5,0.8)', 'STATUS_COMPILE_ERROR', '2023-04-12 09:20:36', '2023-04-12 09:20:41');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (6, -3, '输出格式错误', 'rgba(248,5,5,0.8)', 'STATUS_PRESENTATION_ERROR', '2023-04-12 09:21:57', '2023-04-12 09:22:00');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (7, -1, '答案错误', 'rgba(248,5,5,0.8)', 'STATUS_WRONG_ANSWER', '2023-04-12 09:23:13', '2023-04-12 09:23:15');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (8, 0, '测评通过', 'rgba(35,123,239,0.8)', 'STATUS_ACCEPTED', '2023-04-12 09:23:51', '2023-04-12 09:23:54');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (9, 1, 'CPU时间超限', 'rgba(248,5,5,0.8)', 'STATUS_CPU_TIME_LIMIT_EXCEEDED', '2023-04-12 09:25:09', '2023-04-12 09:25:12');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (10, 2, '真实时间超限', 'rgba(248,5,5,0.8)', 'STATUS_REAL_TIME_LIMIT_EXCEEDED', '2023-04-12 09:28:11', '2023-04-12 09:28:13');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (11, 3, '空间超限', 'rgba(248,5,5,0.8)', 'STATUS_MEMORY_LIMIT_EXCEEDED', '2023-04-12 09:29:57', '2023-04-12 09:29:59');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (12, 4, '运行错误', 'rgba(248,5,5,0.8)', 'STATUS_RUNTIME_ERROR', '2023-04-12 09:31:05', '2023-04-12 09:31:07');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (13, 5, '系统错误', 'rgba(248,5,5,0.8)', 'STATUS_SYSTEM_ERROR', '2023-04-12 09:31:52', '2023-04-12 09:31:55');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (14, 8, 'OI测评部分通过', 'rgba(227,51,117,0.8)', 'STATUS_PARTIAL_ACCEPTED', '2023-04-12 09:34:12', '2023-04-12 09:34:21');
INSERT INTO `judge_result` (`id`, `code`, `name`, `color`, `enums`, `create_time`, `update_time`) VALUES (15, 10, '提交失败', 'rgba(248,5,5,0.8)', 'STATUS_SUBMITTED_FAILED', '2023-04-12 09:34:58', '2023-04-12 09:35:00');
COMMIT;

-- ----------------------------
-- Table structure for language
-- ----------------------------
DROP TABLE IF EXISTS `language`;
CREATE TABLE `language` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `content_type` varchar(255) DEFAULT NULL COMMENT '语言类型',
  `description` varchar(255) DEFAULT NULL COMMENT '语言描述',
  `name` varchar(255) DEFAULT NULL COMMENT '语言名字',
  `compile_command` mediumtext COMMENT '编译指令',
  `template` longtext COMMENT '模板',
  `code_template` longtext COMMENT '语言默认代码模板',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of language
-- ----------------------------
BEGIN;
INSERT INTO `language` (`id`, `content_type`, `description`, `name`, `compile_command`, `template`, `code_template`, `create_time`, `update_time`) VALUES (1, 'C', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `language` (`id`, `content_type`, `description`, `name`, `compile_command`, `template`, `code_template`, `create_time`, `update_time`) VALUES (2, 'C With O2', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `language` (`id`, `content_type`, `description`, `name`, `compile_command`, `template`, `code_template`, `create_time`, `update_time`) VALUES (3, 'C++', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `language` (`id`, `content_type`, `description`, `name`, `compile_command`, `template`, `code_template`, `create_time`, `update_time`) VALUES (4, 'C++ With O2', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `language` (`id`, `content_type`, `description`, `name`, `compile_command`, `template`, `code_template`, `create_time`, `update_time`) VALUES (5, 'C++ 17', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `language` (`id`, `content_type`, `description`, `name`, `compile_command`, `template`, `code_template`, `create_time`, `update_time`) VALUES (6, 'JAVA', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `language` (`id`, `content_type`, `description`, `name`, `compile_command`, `template`, `code_template`, `create_time`, `update_time`) VALUES (7, 'Python2', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `language` (`id`, `content_type`, `description`, `name`, `compile_command`, `template`, `code_template`, `create_time`, `update_time`) VALUES (8, 'Python3', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `language` (`id`, `content_type`, `description`, `name`, `compile_command`, `template`, `code_template`, `create_time`, `update_time`) VALUES (11, 'Golang', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
COMMIT;

-- ----------------------------
-- Table structure for mail
-- ----------------------------
DROP TABLE IF EXISTS `mail`;
CREATE TABLE `mail` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `mail_name` varchar(50) NOT NULL COMMENT '邮箱名称',
  `mail_pwd` varchar(50) NOT NULL COMMENT '邮箱校验码',
  `mail_type` varchar(20) NOT NULL COMMENT '如QQ',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of mail
-- ----------------------------
BEGIN;
INSERT INTO `mail` (`id`, `mail_name`, `mail_pwd`, `mail_type`, `create_time`, `update_time`) VALUES (1, '3543006173@qq.com', 'kxukwmualegwcjce', 'QQ', '2023-03-04 23:11:10', '2023-05-23 16:01:51');
COMMIT;

-- ----------------------------
-- Table structure for mail_log
-- ----------------------------
DROP TABLE IF EXISTS `mail_log`;
CREATE TABLE `mail_log` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `from_mail` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '发送的邮箱',
  `to_mail` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '送达的邮箱',
  `username` varchar(50) DEFAULT NULL,
  `status` int DEFAULT '0' COMMENT '0 未发送 1已经发送',
  `is_ok` int DEFAULT NULL COMMENT '1发送失败',
  `type` varchar(20) DEFAULT NULL COMMENT '发送邮件类型  登录类，注册类',
  `code` varchar(20) DEFAULT NULL COMMENT '验证码',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=117 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of mail_log
-- ----------------------------


-- ----------------------------
-- Table structure for problem
-- ----------------------------
DROP TABLE IF EXISTS `problem`;
CREATE TABLE `problem` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Id 默认1000开始',
  `judge_mode` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'default' COMMENT '判题模式 -default interactive',
  `tilte` varchar(255) NOT NULL COMMENT '题目标题',
  `author` varchar(20) NOT NULL COMMENT '作者',
  `content_description` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '题目内容描述',
  `input_description` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '输入描述',
  `output_description` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '输出描述',
  `input_case` longtext CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '输入案例',
  `output_case` longtext CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '输出案例',
  `gid` int DEFAULT '0' COMMENT '团队id',
  `tid` int DEFAULT '0' COMMENT '训练id',
  `cid` int DEFAULT '0' COMMENT '比赛id',
  `type` int unsigned NOT NULL DEFAULT '1' COMMENT '0为ACM 1为OI',
  `time_limit` int NOT NULL DEFAULT '1000' COMMENT '时间限制(ms)默认为C/C++限制，其他语言为双倍',
  `memory_limit` int NOT NULL DEFAULT '256' COMMENT '空间限制(mb)默认为C/C++限制，其他语言双倍',
  `stack_limit` int unsigned NOT NULL DEFAULT '128' COMMENT '栈限制(mb),默认为128mb',
  `tag` int DEFAULT NULL COMMENT '标签',
  `source` int DEFAULT NULL COMMENT '题目来源',
  `difficulty` int NOT NULL DEFAULT '0' COMMENT '题目难度 0 1 2 3 4 5',
  `hint` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '提示',
  `oi_score` int unsigned NOT NULL DEFAULT '100' COMMENT 'Oi题目时的分数，默认为100',
  `case_num` int unsigned NOT NULL DEFAULT '0' COMMENT '测试案例数量',
  `case_version` varchar(50) DEFAULT '1' COMMENT '版本号',
  `problem_status` int unsigned NOT NULL DEFAULT '1' COMMENT '题目当前状态 1 公开 2 为私有 3为比赛中',
  `open_case_result` int DEFAULT NULL COMMENT '是否开启该题的测试样例查看 0关闭 1开启',
  `modified_user` varchar(20) NOT NULL COMMENT '最后修改题目的用户',
  `status` int NOT NULL DEFAULT '1' COMMENT '题目状态 0为不可见，1为可见',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1063 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of problem
-- ----------------------------


-- ----------------------------
-- Table structure for problem_case
-- ----------------------------
DROP TABLE IF EXISTS `problem_case`;
CREATE TABLE `problem_case` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Id',
  `pid` int unsigned NOT NULL COMMENT '题目id',
  `input` varchar(20) NOT NULL COMMENT '样例输入文件名',
  `output` varchar(20) NOT NULL COMMENT '样例输出文件名',
  `score` int unsigned DEFAULT '0' COMMENT '每个测试案例的oi得分',
  `status` int DEFAULT '1' COMMENT '状态 0 不可用 1可用',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `pid` (`pid`)
) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of problem_case
-- ----------------------------


-- ----------------------------
-- Table structure for problem_tag
-- ----------------------------
DROP TABLE IF EXISTS `problem_tag`;
CREATE TABLE `problem_tag` (
  `id` int NOT NULL COMMENT 'id',
  `tid` int DEFAULT NULL,
  `pid` int unsigned NOT NULL,
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `tid` (`pid`),
  CONSTRAINT `problem_tag_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `tag` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of problem_tag
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for reply
-- ----------------------------
DROP TABLE IF EXISTS `reply`;
CREATE TABLE `reply` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `comment_id` int unsigned DEFAULT NULL COMMENT '被回复的评论id',
  `reply_id` int DEFAULT NULL,
  `level` int DEFAULT '1',
  `did` int unsigned DEFAULT '0' COMMENT '论坛id',
  `gid` int unsigned DEFAULT '0' COMMENT '团队id',
  `tid` int unsigned DEFAULT '0' COMMENT '训练id',
  `cid` int unsigned DEFAULT '0' COMMENT '比赛id',
  `from_uid` int unsigned NOT NULL COMMENT '发起回复的用户id',
  `from_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '发起回复的用户名',
  `from_avatar` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '发起回复的用户头像地址',
  `from_role` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '发起回复的用户角色',
  `to_uid` int unsigned NOT NULL COMMENT '被回复的用户id',
  `to_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '被回复的用户名',
  `to_avatar` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '被回复的用户头像地址',
  `content` longtext COMMENT '回复的内容',
  `status` int DEFAULT '0' COMMENT '是否封禁或逻辑删除该回复 0否 1是',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `comment_id` (`comment_id`),
  CONSTRAINT `reply_ibfk_1` FOREIGN KEY (`comment_id`) REFERENCES `comment` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of reply
-- ----------------------------


-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `role` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色字符串',
  `description` varchar(50) NOT NULL COMMENT '角色描述',
  `status` tinyint(1) NOT NULL COMMENT '0可用1不可用',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of role
-- ----------------------------
BEGIN;
INSERT INTO `role` (`id`, `role`, `description`, `status`, `create_time`, `update_time`) VALUES (1, 'super_admin', '超级管理员', 1, '2023-03-03 09:51:38', '2023-03-03 09:51:42');
INSERT INTO `role` (`id`, `role`, `description`, `status`, `create_time`, `update_time`) VALUES (2, 'admin', '管理员', 1, '2023-03-03 09:52:35', '2023-03-03 09:52:37');
INSERT INTO `role` (`id`, `role`, `description`, `status`, `create_time`, `update_time`) VALUES (3, 'contest_admin', '比赛管理员', 1, '2023-03-03 09:53:05', '2023-03-03 09:53:07');
INSERT INTO `role` (`id`, `role`, `description`, `status`, `create_time`, `update_time`) VALUES (4, 'problem_admin', '题目管理员', 1, '2023-03-03 09:53:47', '2023-03-03 09:53:50');
INSERT INTO `role` (`id`, `role`, `description`, `status`, `create_time`, `update_time`) VALUES (5, 'discussion_admin', '论坛管理员', 1, '2023-03-03 09:54:25', '2023-03-03 09:54:28');
INSERT INTO `role` (`id`, `role`, `description`, `status`, `create_time`, `update_time`) VALUES (6, 'group_admin', '团队管理员', 1, '2023-03-03 09:54:57', '2023-03-03 09:55:00');
INSERT INTO `role` (`id`, `role`, `description`, `status`, `create_time`, `update_time`) VALUES (7, 'user', '普通用户', 1, '2023-03-29 14:50:31', '2023-03-29 14:50:34');
INSERT INTO `role` (`id`, `role`, `description`, `status`, `create_time`, `update_time`) VALUES (8, 'test', '测试用户', 1, '2023-03-29 22:51:33', '2023-03-29 22:51:36');
COMMIT;

-- ----------------------------
-- Table structure for source
-- ----------------------------
DROP TABLE IF EXISTS `source`;
CREATE TABLE `source` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of source
-- ----------------------------
BEGIN;
INSERT INTO `source` (`id`, `name`, `create_time`, `update_time`) VALUES (1, 'd1', '2023-03-30 16:48:28', '2023-03-30 16:48:44');
INSERT INTO `source` (`id`, `name`, `create_time`, `update_time`) VALUES (2, 'd2', '2023-03-30 16:48:55', '2023-03-30 16:48:58');
INSERT INTO `source` (`id`, `name`, `create_time`, `update_time`) VALUES (3, 'd3', '2023-03-30 16:49:06', '2023-03-30 16:49:08');
INSERT INTO `source` (`id`, `name`, `create_time`, `update_time`) VALUES (4, 'd4', '2023-03-30 16:49:20', '2023-03-30 16:49:23');
INSERT INTO `source` (`id`, `name`, `create_time`, `update_time`) VALUES (6, '测试类别', '2023-04-25 08:40:15', '2023-04-25 08:40:15');
COMMIT;

-- ----------------------------
-- Table structure for tag
-- ----------------------------
DROP TABLE IF EXISTS `tag`;
CREATE TABLE `tag` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Id',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标签名字',
  `color` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '标签颜色',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of tag
-- ----------------------------
BEGIN;
INSERT INTO `tag` (`id`, `name`, `color`, `create_time`, `update_time`) VALUES (1, '入门', NULL, '2023-03-30 15:42:53', '2023-03-30 15:42:55');
INSERT INTO `tag` (`id`, `name`, `color`, `create_time`, `update_time`) VALUES (2, '普及-', NULL, '2023-03-30 15:43:43', '2023-03-30 15:43:45');
INSERT INTO `tag` (`id`, `name`, `color`, `create_time`, `update_time`) VALUES (3, '提高+', NULL, '2023-03-30 15:44:20', '2023-03-30 15:44:23');
INSERT INTO `tag` (`id`, `name`, `color`, `create_time`, `update_time`) VALUES (4, '普及+', NULL, '2023-03-30 15:44:39', '2023-03-30 15:44:41');
INSERT INTO `tag` (`id`, `name`, `color`, `create_time`, `update_time`) VALUES (5, '提高-', NULL, '2023-03-30 15:44:56', '2023-03-30 15:45:06');
INSERT INTO `tag` (`id`, `name`, `color`, `create_time`, `update_time`) VALUES (6, '省选', NULL, '2023-03-30 15:45:29', '2023-03-30 15:45:32');
COMMIT;

-- ----------------------------
-- Table structure for training
-- ----------------------------
DROP TABLE IF EXISTS `training`;
CREATE TABLE `training` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) DEFAULT NULL COMMENT '训练题单名称',
  `description` longtext COMMENT '训练题单简介',
  `author` varchar(255) NOT NULL COMMENT '训练题单创建者用户名',
  `auth` int NOT NULL DEFAULT '1' COMMENT '训练题单权限类型：Public -1、Private-2',
  `private_pwd` varchar(255) DEFAULT NULL COMMENT '训练题单权限为Private时的密码',
  `category` int DEFAULT NULL COMMENT '类别',
  `status` int DEFAULT '1' COMMENT '是否可用',
  `is_group` int DEFAULT '0',
  `gid` int unsigned DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `training_ibfk_1` (`gid`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of training


-- ----------------------------
-- Table structure for training_category
-- ----------------------------
DROP TABLE IF EXISTS `training_category`;
CREATE TABLE `training_category` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL COMMENT '类别名称',
  `color` varchar(255) DEFAULT NULL COMMENT '颜色',
  `gid` int unsigned DEFAULT NULL COMMENT '团队id',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `training_category_ibfk_1` (`gid`),
  CONSTRAINT `training_category_ibfk_1` FOREIGN KEY (`gid`) REFERENCES `group` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of training_category
-- ----------------------------
BEGIN;
INSERT INTO `training_category` (`id`, `name`, `color`, `gid`, `create_time`, `update_time`) VALUES (1, '图', 'red', NULL, '2023-04-03 14:44:22', '2023-04-03 14:44:24');
INSERT INTO `training_category` (`id`, `name`, `color`, `gid`, `create_time`, `update_time`) VALUES (2, '树', NULL, NULL, '2023-04-03 14:44:43', '2023-04-03 14:44:46');
INSERT INTO `training_category` (`id`, `name`, `color`, `gid`, `create_time`, `update_time`) VALUES (3, '递归', NULL, NULL, '2023-04-03 14:45:02', '2023-04-03 14:45:05');
INSERT INTO `training_category` (`id`, `name`, `color`, `gid`, `create_time`, `update_time`) VALUES (4, '动态规划', NULL, NULL, '2023-04-03 14:45:18', '2023-04-03 14:45:21');
INSERT INTO `training_category` (`id`, `name`, `color`, `gid`, `create_time`, `update_time`) VALUES (5, '字符串', NULL, NULL, '2023-04-03 14:45:35', '2023-04-03 14:45:38');
COMMIT;

-- ----------------------------
-- Table structure for training_problem
-- ----------------------------
DROP TABLE IF EXISTS `training_problem`;
CREATE TABLE `training_problem` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `tid` int unsigned NOT NULL COMMENT '训练id',
  `pid` int unsigned NOT NULL COMMENT '题目id',
  `display_id` varchar(20) DEFAULT NULL COMMENT '展示id',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `tid` (`tid`),
  KEY `pid` (`pid`),
  CONSTRAINT `training_problem_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `training` (`id`),
  CONSTRAINT `training_problem_ibfk_2` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of training_problem
-- ----------------------------

-- ----------------------------
-- Table structure for training_record
-- ----------------------------
DROP TABLE IF EXISTS `training_record`;
CREATE TABLE `training_record` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `tid` int unsigned NOT NULL COMMENT '训练id',
  `tpid` int unsigned NOT NULL COMMENT '训练题目表单id',
  `pid` int unsigned NOT NULL COMMENT '问题id',
  `uid` int unsigned NOT NULL COMMENT '用户id',
  `submit_id` int unsigned NOT NULL COMMENT '提交id',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `training_record_ibfk_1` (`tid`),
  KEY `training_record_ibfk_2` (`tpid`),
  KEY `training_record_ibfk_3` (`pid`),
  KEY `training_record_ibfk_4` (`uid`),
  KEY `training_record_ibfk_5` (`submit_id`),
  CONSTRAINT `training_record_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `training_record_ibfk_2` FOREIGN KEY (`tpid`) REFERENCES `training_problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `training_record_ibfk_3` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `training_record_ibfk_4` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `training_record_ibfk_5` FOREIGN KEY (`submit_id`) REFERENCES `judge` (`submit_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of training_record
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for training_register
-- ----------------------------
DROP TABLE IF EXISTS `training_register`;
CREATE TABLE `training_register` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `tid` int unsigned NOT NULL COMMENT '训练id',
  `uid` int unsigned NOT NULL COMMENT '用户id',
  `status` tinyint(1) DEFAULT '1' COMMENT '是否同意',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `training_register_ibfk_1` (`tid`),
  KEY `training_register_ibfk_2` (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of training_register
-- ----------------------------

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '用户id',
  `username` varchar(16) NOT NULL COMMENT '学号',
  `password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账号密码',
  `nickname` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '用户昵称',
  `realname` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '真实名字',
  `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '邮箱',
  `sex` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '性别',
  `face_url` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '头像地址',
  `signature` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '个性签名',
  `famous_title` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '称号，头衔',
  `oi_score` int unsigned DEFAULT '0' COMMENT 'Oi分数',
  `status` int unsigned DEFAULT '1' COMMENT '1可用 0不可用',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `nickname` (`nickname`),
  KEY `realname` (`realname`)
) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
INSERT INTO `user` (`id`, `username`, `password`, `nickname`, `realname`, `email`, `sex`, `face_url`, `signature`, `famous_title`, `oi_score`, `status`, `create_time`, `update_time`) VALUES (1, '022300190103', '$2a$10$eH95eyBO7ERXyNvcGDTvoOD/KA1dfL8WjWUsZ696rzC4oO.kp684S', '陶子韬', '陈彬', '1507570997@qq.com', '男', 'http://127.0.0.1:8080/file/avatar/user/IMG_0368-20230511104312779.jpg', 'ojXNFJzshGojXNFJzshGojXNFJzshGojXNFJzshGojXNFJzshGojXNFJzshGojXNFJzshGojXNFJzshGojXNFJzshGojXNFJzshG', 'Prof.', 204, 1, '2022-12-02 13:45:40', '2023-05-23 00:00:00');
COMMIT;

-- ----------------------------
-- Table structure for user_ac_problem
-- ----------------------------
DROP TABLE IF EXISTS `user_ac_problem`;
CREATE TABLE `user_ac_problem` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'Id\n',
  `uid` int unsigned NOT NULL COMMENT '用户id',
  `pid` int unsigned NOT NULL COMMENT '题目id',
  `sid` int unsigned NOT NULL COMMENT '提交问题记录的id',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '修改时间',
  PRIMARY KEY (`id`),
  KEY `uid` (`uid`),
  KEY `pid` (`pid`),
  KEY `sid` (`sid`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of user_ac_problem
-- ----------------------------


-- ----------------------------
-- Table structure for user_role
-- ----------------------------
DROP TABLE IF EXISTS `user_role`;
CREATE TABLE `user_role` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `uid` int unsigned NOT NULL COMMENT '用户ID',
  `rid` int unsigned NOT NULL COMMENT '角色ID',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `user_role_ibfk_1` (`uid`),
  KEY `user_role_ibfk_2` (`rid`),
  CONSTRAINT `user_role_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`id`),
  CONSTRAINT `user_role_ibfk_2` FOREIGN KEY (`rid`) REFERENCES `role` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of user_role
-- ----------------------------
BEGIN;
INSERT INTO `user_role` (`id`, `uid`, `rid`, `create_time`, `update_time`) VALUES (1, 1, 1, '2023-03-03 10:50:28', '2023-03-03 10:50:31');
COMMIT;

-- ----------------------------
-- Table structure for user_score
-- ----------------------------
DROP TABLE IF EXISTS `user_score`;
CREATE TABLE `user_score` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `uid` int unsigned NOT NULL COMMENT '用户id',
  `rate` int NOT NULL COMMENT 'Oi分数',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `uid` (`uid`),
  CONSTRAINT `user_score_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of user_score
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for user_sys_notice
-- ----------------------------
DROP TABLE IF EXISTS `user_sys_notice`;
CREATE TABLE `user_sys_notice` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `sys_notice_id` int unsigned DEFAULT NULL COMMENT '系统通知的id',
  `recipient_id` int unsigned DEFAULT NULL COMMENT '接受通知的用户id',
  `state` tinyint(1) DEFAULT '0' COMMENT '是否已读 0未读 1读',
  `create_time` datetime NOT NULL,
  `update_time` datetime DEFAULT NULL COMMENT '读取时间',
  PRIMARY KEY (`id`),
  KEY `sys_notice_id` (`sys_notice_id`),
  KEY `recipient_id` (`recipient_id`),
  CONSTRAINT `user_sys_notice_ibfk_1` FOREIGN KEY (`sys_notice_id`) REFERENCES `admin_sys_notice` (`id`),
  CONSTRAINT `user_sys_notice_ibfk_2` FOREIGN KEY (`recipient_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of user_sys_notice
-- ----------------------------
BEGIN;
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
